package com.yi.apipassenger.controller;

import com.yi.apipassenger.service.VerificationCodeService;
import com.yi.internalcommon.dto.ResponseResult;
import com.yi.internalcommon.request.VerificationCodeDTO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
public class VerificationCodeController {
    @Autowired
    private VerificationCodeService verificationCodeService;

    @GetMapping("/verification-code")
    public ResponseResult verificationCode(@RequestBody VerificationCodeDTO verificationCodeDTO){
        String passengerPhone = verificationCodeDTO.getPassengerPhone();
        ResponseResult responceResult = verificationCodeService.generatorCode(passengerPhone);
        return  responceResult;
    }

    @PostMapping("/verification-code-check")
    public ResponseResult checkVerificationCode(@RequestBody VerificationCodeDTO verificationCodeDTO){
        String passengerPhone = verificationCodeDTO.getPassengerPhone();
        String verificationCode = verificationCodeDTO.getVerificationCode();
        ResponseResult responceResult = verificationCodeService.checkCode(passengerPhone, verificationCode);
        return responceResult;
    }

}
